<?php


namespace app\model;


use think\facade\Cache;
use think\facade\Db;
use think\Model;

class CommodityCate extends Model
{


    /**
     * 商品分类
     * @return mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function CateList()
    {
        //搜索
        $where[] = ['status', '=', 1];
        if (!empty($map['search_name'])) {
            $where[] = ['name', 'like', "{$map['search_name']}%"];
        }
        $list = Db::name('commodity_cate')
            ->field('id,name,pid,type,image,created_time')
            ->where($where)
            ->order('sort desc')
            ->select()
            ->toArray();
        $result = tree($list);
        return app('json')->json_success('成功', $result ?: []);
    }


}